import Router from 'koa-router'
import subscribe from 'redis-subscribe-sse'
import { graphiqlKoa, graphqlKoa } from 'apollo-server-koa';
import schema from '../schema'

const router = new Router()

router.get('/graphiql', graphiqlKoa({ endpointURL: '/graphql' }));
router.all('/graphql', graphqlKoa({
  schema: schema
}));

router.get('/string', async (ctx, next) => {
  ctx.body = 'koa2 string'
})

router.get('/json', async (ctx, next) => {
  ctx.body = {
    title: 'koa2 json'
  }
})

module.exports = router
